package com.example.guet_assistant.config;
import com.example.guet_assistant.Interceptor.JwtTokenUserInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
@Configuration
public class WebMvcConfiguration  extends WebMvcConfigurationSupport {
       @Autowired
       private JwtTokenUserInterceptor   jwtTokenUserInterceptor;


       protected void addInterceptors(InterceptorRegistry registry){
            registry.addInterceptor(jwtTokenUserInterceptor).addPathPatterns("/**")
                            .excludePathPatterns("/user/login/**")
                            .excludePathPatterns("/user/register");

        }



        /**
         * 设置静态资源映射
         * @param registry
         */
        protected void addResourceHandlers(ResourceHandlerRegistry registry) {
                registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/");
                registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
        }
}
